package com.lvchenglong;

import com.lvchenglong.task.TaskHighCpu;
import com.lvchenglong.task.TaskWait;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * A template class for quick start project
 *
 * @author Lv Chenglong
 */
public class JvmTestApp {

    public static List<String> staticTimeList = new ArrayList<>();

    public static byte[] sampleBytes = new byte[1024];

    public static void main(String[] args) {
        staticTimeList.add(LocalDate.now().toString());
        int corePoolSize = 10;
        int maxSize = 50;


        ThreadPoolExecutor executor = new ThreadPoolExecutor(corePoolSize, maxSize,
                0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<>());

        // 五个等待线程
        for (int i=0; i< 5; i++) {
            executor.submit(new TaskWait());
        }

        // 五个CPU线程
        for (int i=0; i< 2; i++) {
            executor.submit(new TaskHighCpu());
        }
    }
}
